#pragma once
#include <boost/lexical_cast.hpp>
#include <string>
#include <vector>
#include "stringUtil.h"
namespace TinyRPC{


// 类型装换    
template <typename T>
class LexicalCast{
public:
    T operator()(const std::string& value){
        return boost::lexical_cast<T>(value);
    }
};

//LexicalCast 对于std::vector的偏特化
template <typename T>
class LexicalCast<std::vector<T>>{
public:
    vector<T> operator()(const string& value){
        vector<string> splitStrings;
        vector<T> results;
        splitString(value, splitStrings, ",");

        for(auto str : splitStrings){
            results.push_back(boost::lexical_cast<T>(trim(str, ' ')));
        }
        return results;
    }
};
}